#ifndef VECTOR2PROPERTY_H
#define VECTOR2PROPERTY_H
#include "StompedReality/Math/Vector2.h"
#include "StomperLib/Controls/Property/TextPropertyBase.h"
#include <iostream>
#include <sstream>
namespace StomperLib {
namespace Controls {
namespace Property {
class Vector2Property : public TextPropertyBase {
 public:

  GWEN_CONTROL_INLINE( Vector2Property, TextPropertyBase )
  {
  }
  bool CopyValueToData( )
  {
    int m = this->m_TextBox->GetText( ).Get( ).find( " " );
    if (m < 0)
    {
//	  CopyDataToValue();
      return false;
    }
    float x = atof( this->m_TextBox->GetText( ).Get( ).substr( 0, m ).c_str( ));
    float y = atof( this->m_TextBox->GetText( ).Get( ).substr( m+1 ).c_str( ));
    StompedReality::Math::Vector2* v = (StompedReality::Math::Vector2*) this->m_DataPointer;
    v->SetX( x );
    v->SetY( y );
    return true;
  }

  void CopyDataToValue( )
  {
    StompedReality::Math::Vector2* v = (StompedReality::Math::Vector2*) this->m_DataPointer;
    std::stringstream stream;
    stream << v->GetX( );
    stream << " ";
    stream << v->GetY( );
    this->m_TextBox->SetText( stream.str( ), false );
  }

};

}
}
}
#endif // ifndef VECTOR2PROPERTY_H